package com.edu.config;

import com.edu.auth.TokenInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ProjectName: summer-project
 * @Titile: AuthConfig
 * @Author: Lucky
 * @Description: 注册token拦截器
 */
@SpringBootConfiguration
public class AuthConfig implements WebMvcConfigurer {
    @Autowired
    private TokenInterceptor tokenInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(tokenInterceptor)
                .addPathPatterns("/**")//拦截所有， /**：通配符
                .excludePathPatterns("/api/emp/login");//放行登录
    }
}
